﻿using APP.QUANLY.Common;
using RMAS.DAL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace RMAS
{
    public partial class frmMain : Form
    {
        public static int funcID;
        private static Panel objPanel = new Panel();
        //public static frmPayAction objPayAction;
        

        public frmMain()
        {
            InitializeComponent();
            objPanel = this.pnlWaiting;
        }

        private void btbMinimine_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }
        private void btnClose_Click(object sender, EventArgs e)
        {
            funcID = -1;
            //if (frmCashier.tableID.Trim().Length > 1)
            //{
            //    frmCashier.tableID = "";
            //    this.splitContainer1.Panel2.Controls.Clear();
            //    frmCashier cashier = new frmCashier();
            //    cashier.TopLevel = false;
            //    cashier.WindowState = FormWindowState.Maximized;
            //    this.splitContainer1.Panel2.Controls.Add(cashier);
            //    this.btnClose.Show();
            //    cashier.Show();
            //}
            //else
            //{
                this.splitContainer1.Panel2.Controls.Clear();
                frmTask task = new frmTask();
                task.TopLevel = false;
                task.WindowState = FormWindowState.Maximized;
                this.splitContainer1.Panel2.Controls.Add(task);
                task.Show();
                this.btnClose.Hide();
            //}
        }
        private void btnExit_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn đóng ứng dụng không ?", "RMAS - Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Application.Exit();
            }
        }

        private void frmDesktop_Load(object sender, EventArgs e)
        {
            StaticVar.LoadAllData();
            frmTask task = new frmTask();
            task.TopLevel = false;
            task.WindowState = FormWindowState.Maximized;
            this.splitContainer1.Panel2.Controls.Add(task);
            task.Show();
            getTableWaitting();
        }

        public static void getTableWaitting()
        {
            objPanel.Controls.Clear();
            //int x = 0;
            //int y = 5;
            //SqlConnection connection = new SqlConnection(Program.strConnectionString);
            //connection.Open();
            //SqlCommand command = connection.CreateCommand();
            //command.CommandText = "SELECT * FROM TabVIPBill WHERE [BillType] = 4";
            //SqlDataReader reader = command.ExecuteReader();
            //while (reader.Read())
            //{
            //    Button button = new Button();
            //    button.Name = reader["BillID"].ToString();
            //    button.Text = reader["TableID"].ToString();
            //    button.Font = new Font("Arial", 7f);
            //    button.Cursor = Cursors.Hand;
            //    button.BackColor = Color.White;
            //    button.Size = new Size(60, 0x18);
            //    button.Location = new Point(x, y);
            //    button.FlatStyle = FlatStyle.Flat;
            //    button.FlatAppearance.BorderColor = Color.FromArgb(0xff, 0xc0, 0xff);
            //    button.Click += new EventHandler(frmDesktop.objButton_Click);
            //    objPanel.Controls.Add(button);
            //    x += 60;
            //}
            //reader.Close();
            //connection.Close();
            //connection.Dispose();
        }
        private static void objButton_Click(object sender, EventArgs e)
        {
            Button button = (Button)sender;
            //frmPayAction action = new frmPayAction();
            //action.lblTableName.Text = button.Text;
            //action.tableID = button.Text;
            //action.currBillID = button.Name;
            //action.ShowDialog();
        }

        private void splitContainer1_Panel2_ControlRemoved(object sender, ControlEventArgs e)
        {
            switch (funcID)
            {
                case 0:
                    {
                        this.splitContainer1.Panel2.Controls.Clear();
                        frmSales sales = new frmSales();
                        sales.TopLevel = false;
                        sales.WindowState = FormWindowState.Maximized;
                        this.splitContainer1.Panel2.Controls.Add(sales);
                        this.btnClose.Show();
                        sales.Show();
                        break;
                    }
                case 1:
                    {
                        //this.splitContainer1.Panel2.Controls.Clear();
                        //frmListBill bill = new frmListBill();
                        //bill.TopLevel = false;
                        //bill.WindowState = FormWindowState.Maximized;
                        //this.splitContainer1.Panel2.Controls.Add(bill);
                        //this.btnClose.Show();
                        //bill.Show();
                        break;
                    }
                case 2:
                    {
                        //this.splitContainer1.Panel2.Controls.Clear();
                        //frmInOutMenu menu = new frmInOutMenu();
                        //menu.TopLevel = false;
                        //menu.WindowState = FormWindowState.Maximized;
                        //this.splitContainer1.Panel2.Controls.Add(menu);
                        //this.btnClose.Show();
                        //menu.Show();
                        break;
                    }
                case 3:
                    {
                        //frmCashier.tableID = "";
                        //this.splitContainer1.Panel2.Controls.Clear();
                        //frmMenuDifine difine = new frmMenuDifine();
                        //difine.TopLevel = false;
                        //difine.WindowState = FormWindowState.Maximized;
                        //this.splitContainer1.Panel2.Controls.Add(difine);
                        //this.btnClose.Show();
                        //difine.Show();
                        break;
                    }
                case 4:
                    {
                        //frmCashier.tableID = "";
                        //this.splitContainer1.Panel2.Controls.Clear();
                        //frmReportMenu menu2 = new frmReportMenu();
                        //menu2.TopLevel = false;
                        //menu2.WindowState = FormWindowState.Maximized;
                        //this.splitContainer1.Panel2.Controls.Add(menu2);
                        //this.btnClose.Show();
                        //menu2.Show();
                        break;
                    }
                case 5:
                    {
                        this.splitContainer1.Panel2.Controls.Clear();
                        frmDanhMuc danhmuc = new frmDanhMuc();
                        danhmuc.TopLevel = false;
                        danhmuc.WindowState = FormWindowState.Maximized;
                        this.splitContainer1.Panel2.Controls.Add(danhmuc);
                        this.btnClose.Show();
                        danhmuc.Show();
                        break;
                    }
                case 6:
                    {
                        //frmCashier.tableID = "";
                        //this.splitContainer1.Panel2.Controls.Clear();
                        //frmMainSystem system = new frmMainSystem();
                        //system.TopLevel = false;
                        //system.WindowState = FormWindowState.Maximized;
                        //this.splitContainer1.Panel2.Controls.Add(system);
                        //this.btnClose.Show();
                        //system.Show();
                        break;
                    }
                case 7:
                    {
                        //this.splitContainer1.Panel2.Controls.Clear();
                        //frmTabeleDetail detail = new frmTabeleDetail();
                        //detail.TopLevel = false;
                        //detail.WindowState = FormWindowState.Maximized;
                        //this.splitContainer1.Panel2.Controls.Add(detail);
                        //this.btnClose.Show();
                        //detail.Show();
                        break;
                    }
                case 8:
                    {
                        //this.splitContainer1.Panel2.Controls.Clear();
                        //frmSystemMenu menu3 = new frmSystemMenu();
                        //menu3.TopLevel = false;
                        //menu3.WindowState = FormWindowState.Maximized;
                        //this.splitContainer1.Panel2.Controls.Add(menu3);
                        //this.btnClose.Show();
                        //menu3.Show();
                        break;
                    }
            }
        }

       
    }
}
